package com.sfac.springboot.modules.test.controller;

import com.sfac.springboot.modules.test.entity.Country;
import com.sfac.springboot.modules.test.service.CountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author jzq
 * @date 2022/8/18 13:59
 */
@SuppressWarnings({"all"})
@RestController
@RequestMapping("/api")
public class CountryController {

    @Autowired
    private CountryService countryService;


    /**
     * localhost/api/country/522
     *
     * @param countryId
     * @return
     */
    @GetMapping("/country/{countryId}")
    public Country getCountryByCountryId(@PathVariable int countryId) {
        return countryService.getCountryByCountryId(countryId);
    }


    /**
     * localhost/api/country/?countryName=Aruba
     * @param countryName
     * @return
     */
    @GetMapping("/country")
    public Country getCountryByCountryName(@RequestParam String countryName) {
        return countryService.getCountryByCountryName(countryName);
    }


}
